import java.math.BigDecimal;

/**
 * 打折活动策略
 *
 * @author fy
 * @date 2022/8/23 21:50
 */
public class DiscountStrategy implements PriceStrategy {

    /**
     * 打折率
     */
    private final double rate;

    public DiscountStrategy(double rate) {
        this.rate = rate;
    }

    @Override
    public double calcPrice(double originalPrice) {
        return BigDecimal.valueOf(originalPrice).multiply(BigDecimal.valueOf(this.rate)).doubleValue();
    }

}
